<?php defined('IN_NWIDC') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3><?php echo $lang['web_set'];?></h3>
      <ul class="tab-base">
        <li><a href='index.php?act=setting&op=base' ><span>站点设置</span></a></li>
        <li>
          <a href="index.php?act=setting&op=dump"><span>防灌水设置</span></a>
        </li>
        <li>
         <a class="current"><span>保税商品附加字段</span></a>
        </li>
      </ul>
    </div>
  </div>
  <style>
    #main{
      overflow: hidden;
    }
    #main textarea{
      width:40%;
      float: left;
      min-height: 600px;
    }
    #main #result{
      float: right;
      width:49%;
      min-height: 600px;
      border:1px solid #ddd;
      padding: 10px;
    }
    .itips{
      color: red;
    }

    #result dl{
      clear: both;
      overflow: hidden;
      line-height: 35px;
    }
    #result dt,#result dd{
      float: left;
    }
    #result dt{
      font-weight: bold;
      display: block;
      width: 150px;
      text-align: right;
    }
    #result dd{
      padding-left: 15px;
    }
    #result dd input[type='text']{
      width: 200px;
      padding-top: 4px;
      padding-bottom: 4px;
    }
    #result dd #rules{
      padding-top: 6px;
      padding-bottom: 6px;
    }
  </style>
  <div class="fixed-empty"></div>
  <script src='/static/images/coffee.js'></script>
<form method="post" id="settingForm" name="settingForm">
  <input type="hidden" name="form_submit" value="ok" />
  <style type='text/less'>
    .bhead{
       dt{
          font-size: 15px;
          font-weight: bold;
          padding-bottom: 15px;
       }
       dd p{
          line-height: 35px;
          display: block;

          span{
            display: inline-block;
            *display: block;
            width: 150px;
            text-align: right;
          }
       }
    }
  </style>


  <!-- <div class="box">
    <div class="item">
      <span>接口名：<input type='text' name='interface[]' /></span>
    </div>
  </div> -->

  <!-- <p style='color: red;font-size: 18px;'>
      注：此项内容暂时废弃，JSON配置文件请修改网站根目录/custom/config.json，目录中有说明
  </p> -->


  <!-- <div class='bhead'>
    <dl>
      <dt>报文头设置</dt>
      <dd>
        <p>
          <span>报文类型：</span>
          <input type="text" name='head[MessageType]' value='CEB201' />
        </p>
        <p>
          <span>企业组织机构代码：</span>
          <input type="text" name='head[OrgCode]' />
        </p>
        <p>
          <span>发送方：</span>
          <input type="text" name='head[SenderID]'/>
        </p>
        <p>
          <span>接受方：</span>
          <input type="text" name="head[ReceiverID]" >
        </p>
        <p>
          <span>接收部门：</span>
          <select name="head[ReceiverDepartment]" id="">
            <option value="C">海关</option>
            <option value="Q">检验检疫</option>
            <option value="M">市场监管</option>
            <option value="F">外汇</option>
            <option value="T">国税</option>
          </select>
        </p>
        <p>
          <span>版本号：</span>
          <input type='text' name='head[Version]' value='1.0'/>
        </p>
      </dd>
    </dl>
  </div>
  <div style='padding: 20px;font-size: 14px;line-height: 25px;'>
    说明：采用标准json格式声明，可在右边查看实时效果
    <br>
    注：为了解析效率和易用性，此项设定请在IE9+或chrome/firefox/opera等现代浏览器进行
    <br>
    注：你也可以直接修改/admin/goodsextends.json文件来达到相同的效果，填写说明请参照<a style='color:blue' href='/admin/infomation.html' target='_blank'>《字段填写说明》</a>
    <span class='itips'></span>
  </div> -->

    <!-- <div id='main'>
      <textarea name="rules" id="rules" cols="30" rows="10"><?php echo @file_get_contents(BASE_PATH . '/goodsextends.json')?></textarea>

      <div id='result'>

      </div>
    </div> -->

    <div>
      <a href="JavaScript:void(0);" class="btn" onclick="document.settingForm.submit()"><span><?php echo $lang['nc_submit'];?></span></a>
    </div>

    <script type='text/coffeescript'>
      box = $('#result');
      generate = (item)->

        #准备容器
        dl = $ "<dl>"
        dt = $ "<dt>"
        dd = $ "<dd>"
        dl.append(dt).append(dd)
        box.append dl

        dt.append(item.name + " : ") if item.name?
        input = null
        if item.type?
          switch item.type
            when "text"
              input = $('<input type="text"/>')

            when "select"
              input = $('<select><option value="">请选择</option></select>')
              if item.enum?
                for key,val of item.enum
                  input.append("<option value='#{val}'>#{key}</option>")

            when "textarea"
                input = $('<textarea></textarea>')


        if input?
          input.attr
            name : item.field,
            class : "goodsextends",
            "max-length" : item.length,
            "placeholder" : item.tips,

          dd.append input



      $("#main textarea").bind "input propertychange",()->
        val = $(this).val()
        try
          json = eval '(' + val + ')'
          console.log(json)

          $('#result').empty();
          $('.itips').html('')

          generate item for item in json

        catch error
          $('.itips').html('喉呦，解析错误了！请检查输入的内容')

        return true


      $('#main textarea').trigger 'input' if $('#main textarea').val() isnt ''

    </script>
    <!-- <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label><?php echo $lang['allowed_visitors_consult'];?>:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform onoff"><label for="guest_comment_enable" class="cb-enable <?php if($output['list_setting']['guest_comment'] == '1'){ ?>selected<?php } ?>" title="<?php echo $lang['nc_yes'];?>"><span><?php echo $lang['nc_yes'];?></span></label>
            <label for="guest_comment_disabled" class="cb-disable <?php if($output['list_setting']['guest_comment'] == '0'){ ?>selected<?php } ?>" title="<?php echo $lang['nc_no'];?>"><span><?php echo $lang['nc_no'];?></span></label>
            <input id="guest_comment_enable" name="guest_comment" <?php if($output['list_setting']['guest_comment'] == '1'){ ?>checked="checked"<?php } ?> value="1" type="radio">
            <input id="guest_comment_disabled" name="guest_comment" <?php if($output['list_setting']['guest_comment'] == '0'){ ?>checked="checked"<?php } ?> value="0" type="radio"></td>
          <td class="vatop tips"><?php echo $lang['allowed_visitors_consult_notice'];?></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="required"><?php echo $lang['open_checkcode'];?>:</td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><ul class="nofloat">
              <li>
                <input type="checkbox" value="1" name="captcha_status_login" id="captcha_status1" <?php if($output['list_setting']['captcha_status_login'] == '1'){ ?>checked="checked"<?php } ?> />
                <label for="captcha_status1"><?php echo $lang['front_login'];?></label>
              </li>
              <li>
                <input type="checkbox" value="1" name="captcha_status_register" id="captcha_status2" <?php if($output['list_setting']['captcha_status_register'] == '1'){ ?>checked="checked"<?php } ?> />
                <label for="captcha_status2"><?php echo $lang['front_regist'];?></label>
              </li>
              <li>
                <input type="checkbox" value="1" name="captcha_status_goodsqa" id="captcha_status3" <?php if($output['list_setting']['captcha_status_goodsqa'] == '1'){ ?>checked="checked"<?php } ?> />
                <label for="captcha_status3"><?php echo $lang['front_goodsqa'];?></label>
              </li>
            </ul></td>
          <td class="vatop tips" >&nbsp;</td>
        </tr>
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="2" ><a href="JavaScript:void(0);" class="btn" onclick="document.settingForm.submit()"><span><?php echo $lang['nc_submit'];?></span></a></td>
        </tr>
      </tfoot>
    </table> -->
  </form>
</div>
<script src='/static/images/less.js'></script>
